Skip to content

fix resume bug in ParameterUtils, and create tests #104#105

Merged
walterxie merged 2 commits into
masterfrom
resume
Jun 19, 2026
Merged

fix resume bug in ParameterUtils, and create tests #104#105
walterxie merged 2 commits into
masterfrom
resume

Conversation

@walterxie

Copy link
Copy Markdown
Member

Issue #104 :

What the fix does.
parseParameter now uses boundedPattern only as a guard: if a state file still contains the old BEAST2 format with explicit
bounds (e.g. kappa{[0.0,Infinity]}: 1.5), it throws IllegalArgumentException immediately with a clear message explaining
that bounds are now derived from the domain and values can be constrained further through a prior distribution. For all
valid BEAST3 state files, a single noboundPattern branch handles every parameter type — RealScalarParam, IntScalarParam,
RealVectorParam, IntVectorParam, BoolScalarParam, BoolVectorParam — dispatching on the runtime type of param rather than
guessing the type from the string format. The pattern was also made non-greedy (.*?) so the optional {shape} group is
captured correctly for vectors and not swallowed by the leading wildcard. In paramToString, the trailing ", " left over
from the removed BoundedParam call was dropped, so vectors now serialize as freqs{4}: ... and the shape survives the
round-trip.

Why the original code was structured this way.
The original design had two parallel formats: parameters with explicit bounds serialized as kappa{[0.0,Infinity]}: 1.5 and
boolean parameters without bounds serialized as isEstimated: true. The two if/else branches in parseParameter matched
each format and then dispatched to the right type, which was safe because the format uniquely identified the type in
BEAST2 — only booleans lacked bounds. When BoundedParam was removed in BEAST3, the bounds serialization code in
paramToString was commented out but the parsing logic in parseParameter was never updated. Real and integer parameters
then started producing bound-free strings identical in shape to boolean ones, while the parser still assumed bound-free
always meant boolean. The fix collapses the two branches into one: since the serialized string no longer carries enough
information to infer the type, the code simply trusts the type of the param object it was handed.

@walterxie walterxie requested a review from alexeid June 19, 2026 03:16
@walterxie walterxie merged commit 0861c7f into master Jun 19, 2026
1 check passed
@walterxie walterxie deleted the resume branch June 23, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant